/*
 * Copyright (c) ShaoxiongDu <Shaoxiong.dev@aliyun.com> 2021 all Rights Reserved
 */

package zh.codegym.task.task08.task0815;

import java.util.Collection;
import java.util.HashMap;

/* 
人口普查
*/

public class Solution {
    public static HashMap<String, String> createMap() {
        //在此编写你的代码
        HashMap<String, String> strings = new HashMap<String, String>();
        strings.put("名字1", "姓氏");
        strings.put("名字2", "姓氏");
        strings.put("名字3", "姓氏");
        strings.put("名字4", "姓氏");
        strings.put("名字5", "姓氏");
        strings.put("名字6", "姓氏");
        strings.put("名字7", "姓氏");
        strings.put("名字8", "姓氏");
        strings.put("名字9", "姓氏");
        strings.put("名字10", "姓氏");

        return strings;
    }

    public static int getSameFirstNameCount(HashMap<String, String> map, String name) {
        //在此编写你的代码
        int count = 0;
        Collection<String> values = map.values();
        for (String value : values) {
            if (value.equals(name)) {
                count++;
            }
        }
        return count;
    }

    public static int getSameLastNameCount(HashMap<String, String> map, String lastName) {
        //在此编写你的代码
        int count = 0;
        Collection<String> keySet = map.keySet();
        for (String key : keySet) {
            if (key.equals(lastName)) {
                count++;
            }
        }
        return count;
    }

    public static void main(String[] args) {

    }
}
